package com.yylending.las.lending.process.supplyinfo;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yylending.las.Global;
import com.yylending.las.common.AESEntity;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * M:补充资料
 * Created by fan on 2017/6/16.
 * Copyright  2017 www.yylending.com. All Rights Reserved.
 */
public class SupplementInfoModel extends Model {
	private static final String TAG = SupplementInfoModel.class.getSimpleName();
	static final int FUNCTION_CODE_SAVE_SUPPLY_INFO = 2;

	@Override
	public Observable getObservable(Object params, int functionalCode) {
		Service service = (Service) NetworkHelper.createService(Service.class);
		switch (functionalCode) {
			case FUNCTION_CODE_SAVE_SUPPLY_INFO:
				return service.saveSupplyInfo(Global.LOGIN_TOKEN, (AESEntity) params);

		}
		return null;
	}

	@Override
	public void onNext(Object entity) {
		BaseResultEntity result = cast(entity);
		switch (result.requestCode) {
			case FUNCTION_CODE_SAVE_SUPPLY_INFO:
				SaveSupplyInfoResult baseInfo = cast(entity);
				EventAgent.post(baseInfo);
				break;
		}
	}

	private interface Service {
		@POST("server/customer/addInfo")
		Observable<SaveSupplyInfoResult> saveSupplyInfo(@Header("token") String token, @Body AESEntity params);
	}

	public static class SupplyInfo {
		/**
		 * 入职时间或公司成立时间
		 */
		String workStart = "";
		/**
		 * 公司地址-省
		 */
		String comAddP = "";
		/**
		 * 公司地址-市
		 */
		String comAddC = "";
		/**
		 * 公司地址-区
		 */
		String comAddD = "";
		/**
		 * 公司详细地址
		 */
		String comAddS = "";
		/**
		 * 居住地址-省
		 */
		String liveAddP = "";
		/**
		 * 居住地址-市
		 */
		String liveAddC = "";
		/**
		 * 居住地址-区
		 */
		String liveAddD = "";
		/**
		 * 居住地址详细
		 */
		String liveAddS = "";
		/**
		 * 家属电话
		 */
		String familyPhone = "";
		/**
		 * 家属姓名
		 */
		String familyName = "";
		/**
		 * 与本人关系
		 */
		String familyRelation = "";
		/**
		 * 公司的区号
		 */
		String comPhoneD = "";
		/**
		 * 公司的座机
		 */
		String comPhoneN = "";
		/**
		 * 公司的分机号
		 */
		String comPhoneS = "";
	}

	static class SaveSupplyInfoResult extends BaseResultEntity {
	}
}
